package acm.天梯赛练习2;

import java.util.Scanner;

public class C {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int count = sc.nextInt();
        while (count-- > 0) {
            int n=sc.nextInt();
            int res=(2+2*(n-1))*n/2;
            System.out.println(res%10000);
        }
    }
}
